<template>
  <div class="box5">
    <div class="title">
      <p>未来七天游客数量趋势图</p>
      <img src="../../images/dataScreen-title.png" alt="" />
    </div>
    <div class="charts" ref="charts"></div>
  </div>
</template>

<script setup lang="ts">
import * as echarts from 'echarts'
import { ref, onMounted } from 'vue'
//获取图形图标的节点
let charts = ref()
onMounted(() => {
  let mycharts = echarts.init(charts.value)
  mycharts.setOption({
    // title: {
    //     text: '访问量趋势图'
    // },
    tooltip: {
      show: true, // 弹层数据去掉
    },
    xAxis: {
      type: 'category',
      //坐标轴两边留白策略，类目轴和非类目轴的设置和表现不一样
      boundaryGap: false,
      //分割线
      splitLine: {
        show: false,
      },
      //轴线设置
      axisLine: {
        show: true,
      },
      //坐标轴刻度相关设置
      axisTick: {
        show: true,
      },
      data: [
        {
          value: '周一',
          // 突出周一
          textStyle: {
            color: 'red',
          },
        },
        '周二',
        '周三',
        '周四',
        '周五',
        '周六',
        '周日',
      ],
    },
    yAxis: {
      //分割线
      splitLine: {
        show: false,
      },
      //轴线设置
      axisLine: {
        show: true,
      },
      //坐标轴刻度相关设置
      axisTick: {
        show: true,
      },
    },
    grid: {
      left: 40,
      top: 0,
      right: 0,
      bottom: 20,
    },
    series: [
      {
        type: 'line',
        data: [120, 240, 99, 1450, 550, 1200, 180],
        //平滑曲线的设置
        smooth: true,

        //区域填充样式
        areaStyle: {
          color: {
            type: 'linear',
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [
              {
                offset: 0,
                color: 'red', // 0% 处的颜色
              },
              {
                offset: 1,
                color: 'blue', // 100% 处的颜色
              },
            ],
            global: false, // 缺省为 false
          },
        },
      },
    ],
  })
})
</script>

<style scoped lang="scss">
.box5 {
  width: calc(100% - 40px);
  height: 100%;
  background: url(../../images/dataScreen-main-cb.png) no-repeat;
  background-size: 100% 100%;
  margin: 0px 20px;
  margin-bottom: 10px;

  .title {
    margin-left: 20px;

    p {
      color: white;
      font-size: 20px;
    }
  }

  .charts {
    height: calc(100% - 40px);
  }
}
</style>
